<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
      xmlns:a="http://richfaces.org/a4j"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:s="http://jboss.com/products/seam/taglib"
      xmlns:x="http://xseam.dev.java.net/seam"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:fn="http://java.sun.com/jsp/jstl/functions"
      template="/layout/template.xhtml">
	<ui:define name="body">
	
		<h2>Pesquisar saídas</h2>
		<hr style="color: #666666;width: 700px;float: left;"/>
		<br />
		<br />
	
		<x:form id="saidaForm" showMessages="true">
			<s:div id="divDocente">
				<h:outputText value="Docente: " />
				<br class="clear" />
				<h:selectOneMenu id="inDocente" value="#{saidaSearchFilter.docente}" label="Docente: " > 
					<ui:insert />
					<s:selectItems label="#{_docente.nome}" itemValue="#{_docente}" var="_docente" value="#{factoryDocentes}" noSelectionLabel="Selecione..."/>
					<a:support event="onchange" actionListener="#{saidaAction.escondeCampos}" reRender="divDocente,panelCampos" ajaxSingle="true"  /> 
					<s:convertEntity />
					<ui:insert /> 
				</h:selectOneMenu>
			</s:div>
			<br class="clear" />
		
			<a:outputPanel id="panelCampos">
				<s:div rendered="#{saidaAction.exibeCampos}">
				
					<x:inputText id="inSaida1" 
						label="Ano início: " value="#{saidaSearchFilter.anoInicio}" maxlength="4" size="15" />
					<br class="clear" />
					
					<x:inputText id="inSaida2" 
						label="Ano fim: " value="#{saidaSearchFilter.anoFim}" maxlength="4" size="15" />
					<br class="clear" />
				
					<x:selectOneMenu id="inTipo" items="#{factoryTipoSaida}" value="#{saidaSearchFilter.tipoSaida}" label="Saída: " > 
						<ui:insert />
						<f:selectItem itemLabel="Selecione" itemValue=""/>
						<s:selectItems label="#{enumObj.description}" itemValue="#{enumObj.value}" var="enumObj" value="#{factoryTipoSaida}" />
						<ui:insert />
					</x:selectOneMenu>
					<br class="clear" />
				
					<x:selectOneMenu id="inSemestre" items="#{factorySemestre}" value="#{saidaSearchFilter.semestreSaida}" label="Semestre: " > 
						<ui:insert />
						<f:selectItem itemLabel="Selecione" itemValue=""/>
						<s:selectItems label="#{enumObj.description}" itemValue="#{enumObj.value}" var="enumObj" value="#{factorySemestre}" />
						<ui:insert />
					</x:selectOneMenu>
					<br class="clear" />
					
				</s:div>
			</a:outputPanel>
			
			<s:div styleClass="actionButtons">
				<h:commandButton id="btnSearch" 
					value="Pesquisar" action="#{saidaAction.pesquisar()}" title="Pressione aqui para realizar a pesquisa."/>
				<rich:spacer width="5px;"/>
				<h:commandButton id="btnClean" 
					value="Limpar" action="RESULT_BACK" immediate="true" title="Pressione aqui para limpar."/>
				<rich:spacer width="5px;"/>
				<h:commandButton id="btnIncluir" 
					value="Incluir" action="RESULT_INSERT" immediate="true" title="Pressione aqui para incluir um novo registro." rendered="#{identity.loggedIn and (identity.hasRole('Administrador') or identity.hasRole('Coordenador'))}"/>
			</s:div>
			
			<s:div id="divTabela" style="width:600px;" >
			
				<rich:dataTable id="saidaDataTable" 
					value="#{saidas}" var="_saida" width="600px" rendered="#{saidaAction.exibeDataTable}">
					
					<f:facet name="header">
						<rich:columnGroup>
							<rich:column width="5%">
								<h:outputText value="Código"/>
							</rich:column>
							<rich:column width="50%">
								<h:outputText value="Nome" />
							</rich:column>				
							<rich:column width="10%">
								<h:outputText value="Ano" />
							</rich:column>
							<rich:column width="20%">
								<h:outputText value="Semestre" />
							</rich:column>
							<rich:column width="15%">
								<h:outputText value="Ações" />
							</rich:column>
						</rich:columnGroup>
					</f:facet>
					
					<rich:column>
						<h:outputText value="#{_saida.id}" />
					</rich:column>
					<rich:column>
						<h:outputText value="#{_saida.docente.nome}" />
					</rich:column>
					<rich:column>
						<h:outputText value="#{_saida.anoSaida}" />
					</rich:column>
					<rich:column>
						<h:outputText value="#{_saida.semestreSaidaDescription}" />
					</rich:column>
					<rich:column>
						<s:div style="float:left" rendered="#{identity.loggedIn and (identity.hasRole('Administrador') or identity.hasRole('Coordenador'))}">
							<h:commandButton id="btnEditar" 
								value="Editar" action="#{saidaAction.editar(_saida)}" image="/estatico/img/lapis.gif" 
								title="Pressione aqui para editar." onclick="return confirmarOperacao();"/>
						</s:div>
						<s:div style="float:left" rendered="#{identity.loggedIn and (identity.hasRole('Administrador') or identity.hasRole('Coordenador'))}">
							<h:commandButton id="btnExcluir" 
								value="Excluir" action="#{saidaAction.excluir(_saida)}" image="/estatico/img/excluir_lista.gif" 
								title="Pressione aqui para excluir." onclick="return confirmarOperacao();" />
						</s:div>
						<s:div style="float:left">
							<h:commandButton id="btnDetalhar" 
								value="Detalhar" action="#{saidaAction.detalhar(_saida)}" image="/estatico/img/detalhe.gif" 
								title="Pressione aqui para detalhar." />
						</s:div>
					</rich:column>
				</rich:dataTable>
			</s:div>
		
		</x:form>
		
	</ui:define>
	
</ui:composition>